package ws;

import java.beans.PropertyDescriptor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;


/**
 * todo
 *
 * @author zhengshan
 * @Date 2021/8/27 14:22
 */
public class JsonTest {

    private <T> Map<String, T> listToMap(String keyName, List<T> list){
        Map<String, T> m = new HashMap<String, T>();
        try {
            for (T t : list) {
                PropertyDescriptor pd = new PropertyDescriptor(keyName,
                        t.getClass());
                Method getMethod = pd.getReadMethod();// 获得get方法
                Object o = getMethod.invoke(t);// 执行get方法返回一个Object
                m.put(o.toString(), t);
            }
            return m;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        List<String> after = new ArrayList<String>();
        List<String> before = new ArrayList<String>();
        List<String> end = new ArrayList<String>();
        after.add("a");
        after.add("b");
        before.add("a");
        before.add("b");
        before.add("c");
        end = before.stream().filter(e -> after.contains(e)).collect(Collectors.toList());

    }

    private static Calendar getweekBeginDate() throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
        Calendar cld = Calendar.getInstance(Locale.CHINA);
        cld.setFirstDayOfWeek(Calendar.MONDAY);//以周一为首日
        cld.setTimeInMillis(sdf.parse(sdf.format(new java.util.Date())).getTime());//当前时间
        cld.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);//周一
        return cld;
    }

}
